<!--
 * @Author: your name
 * @Date: 2022-04-14 10:03:06
 * @LastEditTime: 2022-04-14 10:09:37
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\简单的闭包实例220414.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>闭包</title>
</head>

<body>
  <script>
    function geyao() {
      var i = 0

      function b() {
        console.log(++i)
      }
      return b
    }
    var c = geyao();
    c() //1
    c() //2
  </script>
</body>

</html>